<?php

$path = pathinfo('http://treaties.un.org/doc/Publication/MTDSG/');
?>
<pre>
<?php 
var_dump($path); 
var_dump(opendir('http://treaties.un.org/doc/Publication/MTDSG/'));
?>
</pre>
<?php

if ($handle = opendir('http://treaties.un.org/doc/Publication/MTDSG/')) {
    echo "Directory handle: $handle\n";
    echo "Entries:\n";

    /* This is the correct way to loop over the directory. */
    while (false !== ($entry = readdir($handle))) {
        echo "$entry\n";
    }

    /* This is the WRONG way to loop over the directory. */
    while ($entry = readdir($handle)) {
        echo "$entry\n";
    }

    closedir($handle);
} else {
	echo 'error!<br />';
}
//**********************************

$url = 'http://treaties.un.org/doc/Publication/MTDSG/';

$html = file_get_contents($url);

$count = preg_match_all('/<td><a href="([^"]+)">[^<]*<\/a><\/td>/i', $html, $files);

for ($i = 0; $i < $count; ++$i) {
    echo "File: " . $files[1][$i] . "<br />\n";
}

//**********************************
echo getcwd();
?>